<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=9" />
		<meta http-equiv="pragma" content="no-cache" />
		<title>新增广告图片</title>
		<%@ include file="../../common/Admin-list.jsp"%>  
		
		<script type="text/javascript" src="<%=bpath %>Scripts/jquery/jquery.form.js"></script> 			 
		<script type="text/javascript">	
		var IconSize=24; //一级 菜单 24 二级 32
		
		$(function(){
			 $('#typeid').combobox({
			   	 url: '../SysTypeID/queryAll.json?tableName=Site_AD',
			   	 valueField: 'id',
			   	 textField: 'typeName',
			   	 editable : true,
			   	 onSelect: function (rec) { 

			   	 },
			   	 onLoadSuccess: function () { 
			   		 
			        }
			   	 });
			 
			
			
			//保存
			$("#lnbSave").click(function(){		
				$("#addForm").ajaxSubmit({
					url:"../siteAd/save.json",
					type:"POST",
					beforeSubmit:checkForm,
					contentType:"application/x-www-form-urlencoded;charset=UTF-8",
					error:function(){},
					success:function(data){
						if(data.success==true){
							showTip("保存成功，返回列表页面！","succeed");	
							var win = artDialog.open.origin;//来源页面
							win.art.dialog({id: 'addDialog'}).close();
							win.refresh();
						}else{
							art.dialog.alert('保存失败，请确认填写正确！');
						}
					},
				});
			});
			
			$("#fileToUpload").change(function(){
				var objUrl = getObjectURL(this.files[0]) ;
				console.log("objUrl = "+objUrl) ;
				if (objUrl) {
					$("#img0").attr("src", objUrl) ;
				}
			});
			
		});
			
		//建立一個可存取到該file的url
		function getObjectURL(file) {
			var url = null ; 
			if (window.createObjectURL!=undefined) { // basic
				url = window.createObjectURL(file) ;
			} else if (window.URL!=undefined) { // mozilla(firefox)
				url = window.URL.createObjectURL(file) ;
			} else if (window.webkitURL!=undefined) { // webkit or chrome
				url = window.webkitURL.createObjectURL(file) ;
			}
			return url ;
		}
		
		function checkForm(){
			var flag=$('#addForm').form('validate');
			return true;
		}
				
		//消息提示  
		function showTip(mess,icon) {  
		    art.dialog({  
		        id : 'Tip',  
		        title : '消息',  
		        fixed : true,  
		        lock : true,  
		        opacity: .2,  
		        content : mess,  
		        icon : icon,  
		        time : 1  
		    });  
		    setTimeout('originReload()', 1000);  
		}  	
		
		</script>
		
		<script>	
			
			
		</script>

		
</head>
<body>
<!---->
<div>	
    <div id="menu">
        <ul>
            <li>
            	<a id="lnbSave"  onclick="lnbSave_Click">
            		<span><img src="<%=basePath %>pages/Admin/Images/Icon/save.gif" alt="Save" />保存</span>
            	</a>
            </li>
        </ul>
    </div>
    
    <div id="middle"> 
    <form action="../siteAd/save.json" id="addForm" name="addForm" method="post"   enctype="multipart/form-data">   
    <div class="editor">
        <table class="eTable">
        	 <tr class="eTr">
                <td class="name">
                    <label id="Label6" >网页显示</label></td>
                <td>
                    <input  id="visible" name="visible" type="checkbox" checked="checked" value="0"/>                                        
                </td>
                <td valign="top" rowspan="8" width="35%">
                	<div style="width:420px;height:300px;border:1px dashed #000; overflow:scroll;">
						<img src="" id="img0" />
					</div>
                </td>                
            </tr>
            <tr class="eTr">
                <td class="name">
                    <label id="Label5" >广告类型</label></td>
                <td>
                    <select id="typeid"  name="typeid" class="easyui-combobox" style="width:150px;" > </select> 
                	      
                </td>
            </tr>            
            <tr class="eTr">
                <td class="name">
                    <label id="Label4">广告图片</label></td>
                <td>
                    <input id="fileToUpload" name="fileToUpload" class="input"  type="file"></input>                    
                </td>
            </tr>
            <tr class="eTr">
                <td class="name">
                    <label id="Label1" >链接标题</label>
                </td>
                <td>
                	<input id="title" name="title" class="input" ></input>
				</td>
            </tr>
            <tr class="eTr">
                <td class="name">
                    <label id="Label2" >链接路径</label></td>
                <td>
                    <input id="link" name="link" class="input" ></input>
                </td>
            </tr>  
            <tr class="eTr" style="display:none;">
                <td class="name">
                    <label id="Label4">高度</label></td>
                <td>
                    <input id="height" name="height" class="input" style="width: 148px;"  type="text"></input> <label style="color: red;">px</label>
                    
                </td>
            </tr>
            
               <tr class="eTr" style="display:none;">
                <td class="name">
                    <label id="Label4">宽度</label></td>
                <td>
                    <input id="width" name="width" class="input" style="width:148px;"  type="text" ></input> <label style="color: red;">px</label>
                </td>
            </tr>
            
            <tr class="eTr">
                <td class="name">
                    <label id="Label5" >排序</label></td>
                <td>
                    <input id="sortid" name="sortid" class="input"   style="width:148px;"  ></input>
                </td>
            </tr>
            <tr class="eTr">
                <td class="name" valign="top">
                    <label id="Label6" >描述</label></td>
                <td>
                    <textarea cols="3"  id="description" name="description" class="input" style="height: 100px;"></textarea>                                        
                </td>
            </tr>
        </table>       
    </div>
    </form> 
    </div>
</div>
</body>
</html>